﻿using System;
using System.Threading;
using System.Windows;
using System.Windows.Media.Imaging;
using MainView;
using MainView.Windows;

namespace Startup
{
    public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            DateTime now = DateTime.Now;
            AppStartWindow appStartWindow = new AppStartWindow();
            appStartWindow.Show();
            LoadBitmap();
            BaseApp.InitApp(this, e.Args);
            base.OnStartup(e);
            MainWindow mainWindow = new MainWindow();
            Application.Current.MainWindow = mainWindow;
            HomeControl homeControl = new HomeControl();
            homeControl.MainWindow = mainWindow;
            mainWindow.SetHomeControl(homeControl);
            int num = (int)(DateTime.Now - now).TotalMilliseconds;
            if (num < 1000)
            {
                Thread.Sleep(1000 - num);
            }
            appStartWindow.Close();
            mainWindow.Show();
            if (e.Args.Length > 0)
            {
                string text = string.Empty;
                string[] args = e.Args;
                foreach (string text2 in args)
                {
                    text = text + " " + text2;
                }
                mainWindow.OpenPcrFile(text);
            }
        }

        private void LoadBitmap()
        {
            BitmapImage bitmapImage = null;
            try
            {
                bitmapImage = new BitmapImage(new Uri("pack://application:,,,/Startup;component/ExperimentHistoryBitmap/DefaultExpHistory.png", UriKind.RelativeOrAbsolute));
                base.Resources.Add("DefaultExperimentHistorySmallBitmap", bitmapImage);
                bitmapImage = new BitmapImage(new Uri("pack://application:,,,/Startup;component/ExperimentHistoryBitmap/DefaultExpHistoryMouseOver.png", UriKind.RelativeOrAbsolute));
                base.Resources.Add("DefaultExperimentHistoryMouseOverSmallBitmap", bitmapImage);
                bitmapImage = new BitmapImage(new Uri("pack://application:,,,/Startup;component/ExperimentHistoryBitmap/ADExpHistory.png", UriKind.RelativeOrAbsolute));
                base.Resources.Add("ADExpHistorySmallBitmap", bitmapImage);
                bitmapImage = new BitmapImage(new Uri("pack://application:,,,/Startup;component/ExperimentHistoryBitmap/ADExpHistoryMouseOver.png", UriKind.RelativeOrAbsolute));
                base.Resources.Add("ADExpHistoryMouseOverSmallBitmap", bitmapImage);
                bitmapImage = new BitmapImage(new Uri("pack://application:,,,/Startup;component/ExperimentHistoryBitmap/AQExpHistory.png", UriKind.RelativeOrAbsolute));
                base.Resources.Add("AQExpHistorySmallBitmap", bitmapImage);
                bitmapImage = new BitmapImage(new Uri("pack://application:,,,/Startup;component/ExperimentHistoryBitmap/AQExpHistoryMouseOver.png", UriKind.RelativeOrAbsolute));
                base.Resources.Add("AQExpHistoryMouseOverSmallBitmap", bitmapImage);
                bitmapImage = new BitmapImage(new Uri("pack://application:,,,/Startup;component/ExperimentHistoryBitmap/HRMExpHistory.png", UriKind.RelativeOrAbsolute));
                base.Resources.Add("HRMExpHistorySmallBitmap", bitmapImage);
                bitmapImage = new BitmapImage(new Uri("pack://application:,,,/Startup;component/ExperimentHistoryBitmap/HRMExpHistoryMouseOver.png", UriKind.RelativeOrAbsolute));
                base.Resources.Add("HRMExpHistoryMouseOverSmallBitmap", bitmapImage);
                bitmapImage = new BitmapImage(new Uri("pack://application:,,,/Startup;component/ExperimentHistoryBitmap/MeltExpHistory.png", UriKind.RelativeOrAbsolute));
                base.Resources.Add("MeltExpHistorySmallBitmap", bitmapImage);
                bitmapImage = new BitmapImage(new Uri("pack://application:,,,/Startup;component/ExperimentHistoryBitmap/MeltExpHistoryMouseOver.png", UriKind.RelativeOrAbsolute));
                base.Resources.Add("MeltExpHistoryMouseOverSmallBitmap", bitmapImage);
                bitmapImage = new BitmapImage(new Uri("pack://application:,,,/Startup;component/ExperimentHistoryBitmap/RQExpHistory.png", UriKind.RelativeOrAbsolute));
                base.Resources.Add("RQExpHistorySmallBitmap", bitmapImage);
                bitmapImage = new BitmapImage(new Uri("pack://application:,,,/Startup;component/ExperimentHistoryBitmap/RQExpHistoryMouseOver.png", UriKind.RelativeOrAbsolute));
                base.Resources.Add("RQExpHistoryMouseOverSmallBitmap", bitmapImage);
            }
            catch (Exception)
            {
            }
        }
    }
}
